<?php

use yii\db\Migration;

/**
 * Handles the creation of table `order`.
 */
class m170410_031920_create_order_table extends Migration
{
    /**
     * @inheritdoc
     */
    public function up()
    {
        $this->createTable('order', [
            'id' => $this->primaryKey(),
            'member_id'=>$this->integer()->unsigned()->notNull()->defaultValue(0)->comment('会员id'),
            'name'=>$this->string(50)->notNull()->comment('收货人'),
            'province_name'=>$this->string(30)->notNull()->defaultValue(0)->comment('省份'),
            'city_name'=>$this->string(30)->notNull()->defaultValue(0)->comment('城市'),
            'area_name'=>$this->string(30)->notNull()->defaultValue(0)->comment('区域'),
            'detail_address'=>$this->string(50)->notNull()->defaultValue(0)->comment('详细地址'),
            'tel'=>$this->char(12)->notNull()->comment('手机号码'),
            'delivery_id'=>$this->integer(3)->unsigned()->notNull()->comment('配送方式的id'),
			'delivery_name'=> $this->string(30)->notNull()->comment('配送方式的名称'),
			'delivery_price'=>$this->decimal(10,2)->notNull()->unsigned()->comment('配送价格'),
            'pay_type_id'=>$this->integer(4)->notNull()->unsigned()->comment('支付方式'),
            'pay_type_name'=>$this->string()->notNull()->comment('支付名称'),
            'price'=>$this->decimal(10,2)->notNull()->unsigned()->comment('小计'),
            'status'=>$this->integer(4)->notNull()->comment('订单状态0取消1带付款2待发货3代收获4完成'),
            'trade_no'=>$this->string()->notNull()->comment('交易号'),
            'create_time'=>$this->integer()->defaultValue(0)->comment('订单创建时间'),
            'update_time'=>$this->integer()->comment('订单更新时间'),
        ]);
    }

    /**
     * @inheritdoc
     */
    public function down()
    {
        $this->dropTable('order');
    }
}
